<?php
	
	if(!@$_POST['akses'] == true) {
	   die('Akses langsung tidak diperbolehkan!');
	}
    
    include("dboper.php");

    if(!empty($_FILES['txtFoto']['tmp_name'])){
        $myhash = md5_file(@$_FILES['txtFoto']['tmp_name']);
        $namaFoto = $myhash."-".$_FILES['txtFoto']['name'];
        copy($_FILES['txtFoto']['tmp_name'],"../imagedata/".$namaFoto);
        unlink($_POST['txtFotoLama']);
    } else {
        $namaFoto = $_POST['fotoLama'];
    }
    
    $id = $_POST['idAsisten'];
    $nama = $_POST['txtNama'];
    $nim = $_POST['txtNIM'];
    $namaPanggilan = $_POST['txtPanggilan'];
    
    updateAsisten($id,$nama,$namaPanggilan,$nim,$namaFoto);
    
?>
<script>
    alert('Data sukses diubah');
    window.location.href = "./cp.php";
</script>